package IO;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

/*对象流*/
public class oosDemo {
    public static void main(String[] args) throws Exception{
        String name = "张三";
        int age = 23;
        String gender = "男";
        String[] otherInfo ={"是一名学生","广东省广州市","喜欢打羽毛球"};
        Student zs = new Student(name,age,gender,otherInfo);
        System.out.println(zs);
        /*对象输出流在序列化对象时，必须保证序列号对象实现Serializable接口，
        * 如果不实现就会出现notSerializableException异常*/
        FileOutputStream fos = new FileOutputStream("studnet.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(zs);
        System.out.println("写出完毕");
        oos.close();
    }
}
